#!/bin/sh

OUTPUT_FILE=$(pwd)/bsbm-data-interpolation

NB_TRIPLES_EXPECTED=1000000000
NB_TRIPLES_GENERATED=0

SCALE_FACTOR=2

function pow() {
   echo $(( ${1:?} ** ${2:?} ));
}

function mult() {
    echo $(($1 * $2));
}

function main() {
    if [ $# -eq 1 ];
    then
	NB_TRIPLES_EXPECTED=$1;
    fi;

    rm -f $OUTPUT_FILE;

    i=1;
    while [ $NB_TRIPLES_GENERATED -le $NB_TRIPLES_EXPECTED ];
    do
	echo -n "> Iteration $i"; 
	NB_TRIPLES_GENERATED=$(java -cp bin:lib/ssj.jar benchmark.generator.Generator -fc -pc $SCALE_FACTOR -s nt | grep triples | cut -d " " -f 1);
	echo ", SCALE_FACTOR=$SCALE_FACTOR, NB_TRIPLES_GENERATED=$NB_TRIPLES_GENERATED";
	echo -e "$NB_TRIPLES_GENERATED\t$SCALE_FACTOR" >> $OUTPUT_FILE;

	i=$(expr $i + 1);
	SCALE_FACTOR=$(expr $SCALE_FACTOR + $(mult $i 4));
#	SCALE_FACTOR=$(pow 2 $i);
    done;
}

main $@

